from modules.admin.models.Addresses import Addresses
from schemas.address import Create, Update


class AddressService:
    @staticmethod
    def create(form: Create,user):
        form = form.model_dump()
        form['uid'] = user['id']
        data = Addresses.create(form)
        return data

    @staticmethod
    def get_all(current, size):
        data = Addresses.paginate(size, current)
        return data

    @staticmethod
    def get_one(Id: int):
        data = Addresses.find(Id)
        return data

    @staticmethod
    def update(form: Update,ad_id:str):
        data = Addresses.find(ad_id)
        data.update(form.dict())
        return data

    @staticmethod
    def delete(Id):
        data = Addresses.find(Id)
        data.delete()
        return data


